//
//  UIView+DottedLine.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2021/9/23.
//  Copyright © 2021 mac. All rights reserved.
//

#import "UIView+DottedLine.h"

@implementation UIView (DottedLine)


+(void)setViewDottedLineWithView:(UIView*)view withFrame:(CGRect)frame withColor:(UIColor *)color withLineWidth:(CGFloat)lineWidth
{
    
    //虚线
     CAShapeLayer *border = [CAShapeLayer layer];
     //虚线的颜色
     border.strokeColor = color.CGColor;
     //填充的颜色
     border.fillColor = [UIColor clearColor].CGColor;
     
//     CGRect frame = CGRectMake(0, 0, ScreenW,cellH(row));
     //设置路径
     border.path = [UIBezierPath bezierPathWithRect:frame].CGPath;
     
     border.frame = frame;
     //虚线的宽度
     border.lineWidth = 0.5f;
 
     //设置线条的样式
     //border.lineCap = @"square";
     //虚线的间隔
     border.lineDashPattern = @[@4, @2];
     
     [view.layer addSublayer:border];
    
}

@end
